<?php
/**
 * 系统设置节点树
 */
class TreeViewSetting extends CWidget {
    public function run() {
        $child_datas = array(
            array('text' => CHtml::link(Yii::t('setting', 'Create root node'), array('MultiLevelCategories/create', 'parent' => -1), array('target' => 'mask')))
        );
        $root_categories = MultiLevelCategory::model()->findAll('parent_id = 1');
        foreach ($root_categories as $category) {
            $child_datas[] = array(
                'text' => CHtml::link($category->name, array('MultiLevelCategories/index', 'parent' => $category->id), array('target' => 'mask'))
            );
        }
        if (count($child_datas)) {
            $child_datas[] = array('text' => CHtml::link(Yii::t('setting', 'multi_level_categories_settinf_generate_js'), array('MultiLevelCategories/generateJsFile'), array('target' => 'mask')));
        }

//        CVarDumper::dump($child_datas, 10, true);

        $this->render('TreeViewSetting', array('child_datas' => $child_datas));
    }
}